
cmake_minimum_required( VERSION 2.6 )

set( NANE_PLATFORM_IMPL )

if( WIN32 )
    message( STATUS "CRT Win32 Implementation" )
    set( NANE_PLATFORM_IMPL
    core/WinAPI/winapi.h
    core/WinAPI/winapi.cpp
    core/crt/Win32/Win32FileSystem.cpp
    core/crt/Win32/Win32FileSystemImpl_.h
    core/crt/Win32/Win32FileSystemImpl_.cpp
    core/crt/Win32/Win32FileBase_.h
    core/crt/Win32/Win32FileBase_.cpp
    core/crt/Win32/Win32ReadFile_.h
    core/crt/Win32/Win32ReadFile_.cpp
    core/crt/Win32/Win32WriteFile_.h
    core/crt/Win32/Win32WriteFile_.cpp
    core/crt/Win32/Win32Time.cpp
    core/crt/Win32/Win32TimeImpl_.h
    core/crt/Win32/Win32TimeImpl_.cpp
    core/crt/Win32/DynamicModule.cpp
    core/crt/Win32/Win32Backtrace.cpp
    )
    if( MSVC )
        set( NANE_PLATFORM_IMPL ${NANE_PLATFORM_IMPL}
        core/crt/Win32/Win32BacktraceSymbolsMSVC.cpp
        )
    elseif( MINGW )
        set( NANE_PLATFORM_IMPL ${NANE_PLATFORM_IMPL}
        core/crt/Win32/Win32BacktraceSymbolsMinGW.cpp
        )
    else()
        set( NANE_PLATFORM_IMPL ${NANE_PLATFORM_IMPL}
        core/crt/Win32/Win32BacktraceSymbols.cpp
        )
    endif()

elseif( UNIX )
    message( STATUS "CRT POSIX Implementation" )
    set( NANE_PLATFORM_IMPL
    core/crt/POSIX/POSIXFileSystem.cpp
    core/crt/POSIX/POSIXFileSystemImpl_.h
    core/crt/POSIX/POSIXFileSystemImpl_.cpp
    core/crt/POSIX/POSIXFileBase_.h
    core/crt/POSIX/POSIXFileBase_.cpp
    core/crt/POSIX/POSIXReadFile_.h
    core/crt/POSIX/POSIXReadFile_.cpp
    core/crt/POSIX/POSIXWriteFile_.h
    core/crt/POSIX/POSIXWriteFile_.cpp
    core/crt/POSIX/POSIXTime.cpp
    core/crt/POSIX/POSIXTimeImpl_.h
    core/crt/POSIX/POSIXTimeImpl_.cpp
    core/crt/POSIX/DynamicModule.cpp
    )
    if( ANDROID ) # android doesn't have execinfo.h
        set( NANE_PLATFORM_IMPL ${NANE_PLATFORM_IMPL}
        core/crt/Backtrace.cpp
        )
    else()
        set( NANE_PLATFORM_IMPL ${NANE_PLATFORM_IMPL}
        core/crt/POSIX/POSIXBacktrace.cpp
        )
    endif()
else()
    message( STATUS "CRT Standard Implementation" )
    set( NANE_PLATFORM_IMPL
    core/crt/std/StdFileSystem.cpp
    core/crt/std/StdFileSystemImpl_.h
    core/crt/std/StdFileSystemImpl_.cpp
    core/crt/std/StdFileBase_.h
    core/crt/std/StdFileBase_.cpp
    core/crt/std/StdReadFile_.h
    core/crt/std/StdReadFile_.cpp
    core/crt/std/StdWriteFile_.h
    core/crt/std/StdWriteFile_.cpp
    core/crt/std/StdTime.cpp
    core/crt/std/StdTimeImpl_.h
    core/crt/std/StdTimeImpl_.cpp
    core/crt/std/DynamicModule.cpp
    core/crt/Backtrace.cpp
    )
endif()

nane_add_library( core

core/IBase.h
core/ISubSystem.h
core/ILogger.h
core/ILogSystem.h
core/IFileSystem.h
core/ISeekable.h
core/IInput.h
core/IOutput.h
core/IRefCounted.h

core/types.h
core/enum.h
core/conversion.h
core/conversion.cpp
core/conversion_stdstring.h
core/FileLogger.h
core/FileLogger.cpp
core/MemoryStream.h
core/MemoryStream.cpp
core/stackstring.h
core/staticassert.h
core/template_friend.h
core/typetraits.h
core/typetraits_pointer.h
core/typetraits_function.h
core/typetraits_void.h
core/RefCount.h
core/IO.h
core/IO.cpp
core/NullPtr.h
core/IntrusivePtr.h
core/SubSystem.h
core/SubSystemProduct.h
core/Holder.h
core/Manager.h
core/PixelFormat.h

core/function/Bind.h
core/function/ForwardParamT.h
core/function/FunctionBase.h
core/function/FunctionPtr.h
core/function/Functor.h
core/function/MemberFunctionPtr.h

core/crt/Context.h
core/crt/crt.h
core/crt/crt.cpp
core/crt/StdLogger.h
core/crt/StdLogger.cpp
core/crt/LogManager.h
core/crt/LogManager.cpp
core/crt/LogManagerImpl_.h
core/crt/LogManagerImpl_.cpp
core/crt/OutputLogger.h
core/crt/OutputLogger.cpp
core/crt/FileSystem.h
core/crt/FileSystem.cpp
core/crt/ITimeSystem.h
core/crt/Time.h
core/crt/Time.cpp
core/crt/IModule.h
core/crt/Module_.h
core/crt/Module_.cpp
core/crt/DynamicModule.h
core/crt/IModuleSystem.h
core/crt/ModuleManager.h
core/crt/ModuleManager.cpp
core/crt/ModuleManagerImpl_.h
core/crt/ModuleManagerImpl_.cpp
core/crt/defaultErrorHandler.h
core/crt/defaultErrorHandler.cpp
core/crt/Backtrace_.h
core/log.h
core/assert.h
${NANE_PLATFORM_IMPL}
)

foreach( plib ${NANE_PLATFORM_LIBS} )
	target_link_libraries( nane_core ${plib} )
endforeach( plib ${NANE_PLATFORM_LIBS} )

if( MINGW )
    target_link_libraries( nane_core bfd iberty intl )
endif()
